package com.dalin.platform.glb.condition;

import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.dalin.common.pager.Condition;
import com.dalin.common.utils.StringUtils;
import com.dalin.common.utils.search.LuceneUtils;
import com.dalin.platform.loa.LoaConst;

/*****************************************************************************
 * @content: 附件查询条件                                                                                                              *
 * @author : 那建林                                                                                                                                 *
 * @crtDate: 2011-11-20 16:09                                               *
 * @modDate: 2011-11-20 16:09                                               *
 * @version: 1.00                                                           *
 ****************************************************************************/
public class WsGlbAttachmentCondition extends Condition {
	private String bizType; // 业务类型
	private String searchContent; // 检索内容
	private String attachmentName; // 附件名称
	private String bizDesc1; // 
	private String bizDesc2; // 
	private String bizDesc3; // 
	private String bizDesc4; // 
	private String bizDesc1Or; // 
	private String bizDesc2Or; // 
    private Long groupId; // 组ID
    private Long projectId; // 组ID
    private Long createUserId; // 创建人ID
    private String attachmentType; // 附件类型
    private Date createDateBegin; // 起始时间
    private Date createDateEnd; // 结束时间
    private Integer attachmentPaperNum1;    
    private Integer attachmentPaperNum2;
    
    
    public WsGlbAttachmentCondition prepareParams() throws Exception {
        setBaseQueryStr("from GlbAttachmentEntity h");
        setParam("h.projectId", "=", projectId);
        setParam("h.bizType", "=", bizType);
        setParam("h.bizDesc1", "=", bizDesc1);
        setParam("h.bizDesc2", "=", bizDesc2);
        setParam("h.bizDesc3", "=", bizDesc3);
        setParam("h.bizDesc4", "=", bizDesc4);
        setParam("h.attachmentPaperNum", ">=", attachmentPaperNum1);
        setParam("h.attachmentPaperNum", "<", attachmentPaperNum2);
        setParam("h.attachmentType", "like", "%" + attachmentType + "%");
        setParam("h.attachmentName", "like", "%" + attachmentName + "%");
        setParam("h.createUserId", "=", createUserId);
//        setParam("h.createDate", ">=", createDate1);
//        setParam("h.createDate", "<", createDate2);
//        setParam("h.attachmentSize", ">=", attachmentSize1);
//        setParam("h.attachmentSize", "<", attachmentSize2);
        setParam("h.groupId", "=", groupId);
        
        if (!StringUtils.isBlank(searchContent)) {
        	List<String> d = LuceneUtils.search(
            		searchContent, getPageSize(), new File(LoaConst.getFileInfoParam("indexStorePath")));
        	if (StringUtils.isBlank(d)){
        		d.add("@#$%^&");
        	}
        	setParam("h.attachmentSavedName", "in", d);
        }
        
        setOrParam("h.bizDesc1", "=", bizDesc1Or);
        setOrParam("h.bizDesc2", "=", bizDesc2Or);
        return this;
    }
    
	public String getBizType() {
		return bizType;
	}

	public void setBizType(String bizType) {
		this.bizType = bizType;
	}

	public Integer getAttachmentPaperNum1() {
		return attachmentPaperNum1;
	}

	public void setAttachmentPaperNum1(Integer attachmentPaperNum1) {
		this.attachmentPaperNum1 = attachmentPaperNum1;
	}

	public Integer getAttachmentPaperNum2() {
		return attachmentPaperNum2;
	}

	public void setAttachmentPaperNum2(Integer attachmentPaperNum2) {
		this.attachmentPaperNum2 = attachmentPaperNum2;
	}

	public String getAttachmentType() {
		return attachmentType;
	}
	public void setAttachmentType(String attachmentType) {
		this.attachmentType = attachmentType;
	}
	public Date getCreateDateBegin() {
		return createDateBegin;
	}
	public void setCreateDateBegin(Date createDateBegin) {
		this.createDateBegin = createDateBegin;
	}
	public Date getCreateDateEnd() {
		return createDateEnd;
	}
	public void setCreateDateEnd(Date createDateEnd) {
		this.createDateEnd = createDateEnd;
	}
	public String getAttachmentName() {
		return attachmentName;
	}
	public void setAttachmentName(String attachmentName) {
		this.attachmentName = attachmentName;
	}
	public Long getGroupId() {
		return groupId;
	}
	public void setGroupId(Long groupId) {
		this.groupId = groupId;
	}
	public Long getCreateUserId() {
		return createUserId;
	}
	public void setCreateUserId(Long createUserId) {
		this.createUserId = createUserId;
	}

	public String getSearchContent() {
		return searchContent;
	}

	public void setSearchContent(String searchContent) {
		this.searchContent = searchContent;
	}

	public String getBizDesc1() {
		return bizDesc1;
	}

	public void setBizDesc1(String bizDesc1) {
		this.bizDesc1 = bizDesc1;
	}

	public String getBizDesc2() {
		return bizDesc2;
	}

	public void setBizDesc2(String bizDesc2) {
		this.bizDesc2 = bizDesc2;
	}

	public Long getProjectId() {
		return projectId;
	}

	public void setProjectId(Long projectId) {
		this.projectId = projectId;
	}

	public String getBizDesc1Or() {
		return bizDesc1Or;
	}

	public void setBizDesc1Or(String bizDesc1Or) {
		this.bizDesc1Or = bizDesc1Or;
	}

	public String getBizDesc2Or() {
		return bizDesc2Or;
	}

	public void setBizDesc2Or(String bizDesc2Or) {
		this.bizDesc2Or = bizDesc2Or;
	}

	public String getBizDesc3() {
		return bizDesc3;
	}

	public void setBizDesc3(String bizDesc3) {
		this.bizDesc3 = bizDesc3;
	}

	public String getBizDesc4() {
		return bizDesc4;
	}

	public void setBizDesc4(String bizDesc4) {
		this.bizDesc4 = bizDesc4;
	}
}
